feat(block): add Logs block for querying execution logs from workflows#4442
feat(block): add Logs block for querying execution logs from workflows#4442TheodoreSpeaks merged 3 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Introduces corresponding tools ( Updates Reviewed by Cursor Bugbot for commit 164afe6. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR adds a Logs block with three operations (query, get by ID, get execution details) that call internal
Confidence Score: 3/5Three P1 bugs cause silent success on API errors across all three new tools; fix before merging. Three independent P1 findings (one per tool), each causing success: true to be returned on HTTP errors, which will silently corrupt downstream block inputs. The auth changes are sound and carry no regression risk. apps/sim/tools/logs/get_execution.ts, apps/sim/tools/logs/get_log.ts, apps/sim/tools/logs/query.ts Important Files Changed
Sequence DiagramsequenceDiagram
participant WF as Workflow Executor
participant LB as Logs Block
participant QT as logsQueryTool / logsGetTool / logsGetExecutionTool
participant API as /api/logs routes
participant DB as Database
WF->>LB: execute(params)
LB->>QT: dispatch tool with operation params
QT->>API: GET request (internal JWT auto-attached)
API->>API: checkSessionOrInternalAuth(request)
API->>DB: query with permissions INNER JOIN (userId scope)
DB-->>API: rows
API-->>QT: JSON response (200 or 4xx/5xx)
Note over QT: response.ok not checked — errors silently return success:true
QT-->>LB: { success: true, output: ... }
LB-->>WF: result
Reviews (1): Last reviewed commit: "feat(logs): add Logs block for querying ..." | Re-trigger Greptile |
Resolve conflicts in /api/logs and /api/logs/[id] by adopting staging's
new contract pattern (parseRequest, fetchLogDetail, cursor pagination)
and re-applying checkSessionOrInternalAuth on top so the Logs block
tools can call these routes from the executor.
Update tools/logs and the Logs block to match the new API:
- /api/logs returns { data, nextCursor }; drop offset/page/total
- /api/logs/[id] now requires ?workspaceId=... query
- Drop the details='basic'|'full' knob (gone from staging)
- Add cursor, sortBy, sortOrder subblocks
- Use WorkflowLogSummary / WorkflowLogDetail types from contract
…tadata description - Add response.ok check in all three logs tools' transformResponse so a 4xx/5xx body cannot be silently treated as a success payload (defense in depth; the executor already throws on non-2xx before transform runs). - Drop totalTokens from executionMetadata description in block and tool outputs since the snapshot route does not emit it.
Summary
limitto 10 whendetails='full'to prevent multi-MB payload pullsType of Change
Testing
bun run lint— cleanbun run check:api-validation:strict— passedbun run type-check— passedChecklist